Northwoods.GoSilverlight 1.3.5 Assembly
MakeXElement Method
See Also  Send Feedback
Northwoods.GoXam.Model Namespace > GraphLinksModelNodeData<NodeKey> Class : MakeXElement Method

n
the name of the new XElement
Constructs a Linq for XML XElement holding the data of this node.

Syntax

Visual Basic (Declaration) 
Public Overridable Function MakeXElement( _
   ByVal n As XName _
) As XElement
C# 
public virtual XElement MakeXElement( 
   XName n
)

Parameters

n
the name of the new XElement

Return Value

an initialized XElement

Remarks

This constructs a new XElement and adds an XAttribute for each simple property that has a value different from its default value. For each property that is a collection, it adds an XElement with nested item elements. This does not add an element if the collection is empty.

Because the NodeKey type might be a type for which we have an implementation to convert to and from strings for XML, this calls the ConvertNodeKeyToString method, which you can override.

This is implemented as:

            public virtual XElement MakeXElement(XName n) {
              XElement e = new XElement(n);
              e.Add(XHelper.Attribute<NodeKey>("Key", this.Key, default(NodeKey), ConvertNodeKeyToString));
              e.Add(XHelper.Attribute("Category", this.Category, ""));
              e.Add(XHelper.Attribute("IsLinkLabel", this.IsLinkLabel, false));
              e.Add(XHelper.Attribute("IsSubGraph", this.IsSubGraph, false));
              e.Add(XHelper.Attribute("IsSubGraphExpanded", this.IsSubGraphExpanded, true));
              e.Add(XHelper.Attribute("WasSubGraphExpanded", this.WasSubGraphExpanded, false));
              e.Add(XHelper.Attribute<NodeKey>("SubGraphKey", this.SubGraphKey, default(NodeKey), ConvertNodeKeyToString));
              e.Add(XHelper.Elements<NodeKey>("MemberKeys", "Key", this.MemberKeys, ConvertNodeKeyToString));
              e.Add(XHelper.Attribute("Location", this.Location, new Point(Double.NaN, Double.NaN)));
              e.Add(XHelper.Attribute("Text", this.Text, ""));
              return e;
            }
            

If you add properties to this node data class, and if you are using the GraphLinksModel<NodeType,NodeKey,PortKey,LinkType>.Save<NodeDataType,LinkDataType> and GraphLinksModel<NodeType,NodeKey,PortKey,LinkType>.Load<NodeDataType,LinkDataType> methods, you should override this method to add new attributes and/or elements as needed, and you should override LoadFromXElement.

Requirements

See Also

© 2012 All Rights Reserved.